package com.example.administrator.familfinalcialmanagement.ui.adapter;

import android.content.Context;
import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.administrator.familfinalcialmanagement.R;
import com.example.administrator.familfinalcialmanagement.databinding.ItemParentClassNameRightBinding;
import com.example.administrator.familfinalcialmanagement.ui.view.TaoLinear;
import com.example.administrator.familfinalcialmanagement.util.listener.BaseRecyclerViewHolder;
import com.example.administrator.familfinalcialmanagement.util.listener.OnChildListener;
import com.example.administrator.familfinalcialmanagement.util.listener.OnItemClickListener;

import java.util.ArrayList;
import java.util.List;

public class ParentClassNameRightAdapter extends RecyclerView.Adapter<BaseRecyclerViewHolder> {
    private List<String> strings;
    private List<String> secondStrings = new ArrayList<>();
    private Context mcontext;
    ChildClassNameRightAdapter adapter;
    OnChildListener listener;

    public ParentClassNameRightAdapter(Context context, List<String> strings) {
        this.mcontext = context;
        this.strings = strings;

    }

    @Override
    public BaseRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        ItemParentClassNameRightBinding functionBinding = DataBindingUtil.inflate(LayoutInflater.from(mcontext),
                R.layout.item_parent_class_name_right, parent, false);
        functionBinding.setAdapter(this);
        return new TourViewHolder(functionBinding);
    }

    @Override
    public void onBindViewHolder(final BaseRecyclerViewHolder holder, final int position) {
        holder.bindData(strings.get(position));
        TourViewHolder tv = (TourViewHolder) holder;
        tv.tvModuleTitle.setText(strings.get(position));



        TaoLinear taoLinear = new TaoLinear(mcontext, 3);
        taoLinear.setScrollEnabled(false);
        secondStrings.clear();
        secondStrings.add("科目");
        secondStrings.add("科目");
        secondStrings.add("科目");
        secondStrings.add("科目");
        secondStrings.add("科目");
        adapter = new ChildClassNameRightAdapter(mcontext, secondStrings);
        tv.tvRecycler.setLayoutManager(taoLinear);
        tv.tvRecycler.setAdapter(adapter);
        adapter.setOnItemClickLitener(new OnItemClickListener() {
            @Override
            public void onItemClick(View view, int pos) {

            }

            @Override
            public void onItemLongClick(View view, int position) {

            }
        });

    }

    public void setOnChildListener(OnChildListener listener) {
        this.listener = listener;
    }

    @Override
    public int getItemCount() {
        return strings.size();
    }

    public class TourViewHolder extends BaseRecyclerViewHolder<String> {
        ItemParentClassNameRightBinding functionBinding;
        RecyclerView tvRecycler;
        TextView tvModuleTitle;

        public TourViewHolder(ItemParentClassNameRightBinding dataBinding) {
            super(dataBinding.getRoot());
            functionBinding = dataBinding;
            tvRecycler = dataBinding.recycler;
            tvModuleTitle = dataBinding.tvModuleTitle;
        }

        @Override
        public void bindData(String data) {
            functionBinding.setBean(data);
        }
    }

    @Override
    public int getItemViewType(int position) {
        return strings.size();
    }

}
